package com.ycwl.freetv.service;

import android.app.job.JobParameters;
import android.app.job.JobService;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;

public class BootService extends JobService {
    public static final String TAG = "BootService";
    @Override
    public boolean onStartJob(JobParameters params) {
        // 后台启动权限申请
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (!Settings.canDrawOverlays(this)) {
                Log.d(TAG,"request permission");
                Log.w(TAG,"has no permission ACTION_MANAGE_OVERLAY_PERMISSION");
                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                intent.setData(Uri.parse("package:"+getPackageName()));
                startActivity(intent);
            }
        }
        return true;
    }

    @Override
    public boolean onStopJob(JobParameters params) {
        return false;
    }


}
